home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 038a / aplibs91.zip / PWW.BAS < prev    next >
BASIC Source File  |  1991-07-17  |  7KB  |  233 lines

  1.  
  2. '           ┌─────────────────────────────────────────────┐
  3. '           │                                             │
  4. '           │   SCREEN CODER -- HB. Started 7-26-87       │
  5. '           │                                             │
  6. '           │   CREATES INTERACTIVE DATA ENTRY WINDOWS    │
  7. '           │                                             │
  8. '           └─────────────────────────────────────────────┘
  9.  
  10.                            $COMPILE EXE
  11.                            $LIB ALL OFF
  12.                           $ERROR ALL OFF
  13.                         $OPTION CNTLBREAK ON
  14.                             DEFINT A-Z
  15.  
  16.  
  17.  DIM LineBuffer$ (40): DIM FL (40): DIM FC (40)
  18.  '
  19.  IF INSTR (UCASE$ (COMMAND$), "BATCH") THEN BatchMode = -1
  20.  COLOR 9, 0: CLS
  21. Start:
  22.  PRINT
  23.  LOCATE ,,0
  24.  PRINT "    CODE GENERATOR FOR POP-WINDOWS IN ";CHR$(34);_
  25.                                             "ALL-PURPOSE LIBRARY"; CHR$(34)
  26.  PRINT "                 Howard Ballinger M.D.    1987 - 91"
  27.  PRINT
  28.  IF COMMAND$ <> "" THEN
  29.     FlNm$ = EXTRACT$ (COMMAND$, " ")
  30.  ELSE
  31.     IF DIR$ ("*.PW") = "" THEN PRINT "NO FILES MATCHING *.PW FOUND.": END 1
  32.     StLn = CSRLIN
  33.     FILES "*.PW"  '                                    get a directory ...
  34.     PRINT 
  35.     INPUT "NAME OF WINDOW DESIGN FILE TO PROCESS:"; FlNm$
  36.     EndLn = CSRLIN
  37.     FOR Y = StLn TO EndLn: LOCATE Y,1: PRINT SPACE$(80);: NEXT
  38.     LOCATE StLn, 1
  39.     IF FlNm$ = "" THEN PRINT "   CANCELLED BY YOUSER.": END
  40.     IF INSTR (FlNm$, ".") THEN FlNm$ = LEFT$(FlNm$,(INSTR(FlNm$,".")-1))
  41.  END IF
  42.  PRINT "     ... now writing DATA statements to generate PopWindow ";_
  43.                                                                  UCASE$ (FlNm$)
  44.  PRINT
  45.  PRINT "Input file ";UCASE$(FlNm$)+".PW  --> Output file ";UCASE$(FlNm$)+".INC";
  46. '                                                 file names are now set ...
  47.  PRINT ". Reading line ";
  48.  L0 = CSRLIN: C0 = POS
  49.  IFLine = 1
  50.  
  51.  PRINT
  52.  
  53. OpenFiles:
  54.  
  55.  IF DIR$ (FlNm$+ ".PW") = "" THEN GOTO NoSuchInputFl
  56.  OPEN FlNm$+".PW" FOR INPUT AS 1
  57.  OPEN FlNm$+".INC" FOR OUTPUT AS 2
  58.  
  59.  
  60. '=========================== START PROCESSING INPUT FILE ======================
  61.  
  62. SkipBlanks:
  63.  L = 0
  64.  DO
  65.    INCR L: LINE INPUT #1, Nput$                ' skip blank lines
  66.    GOSUB Show
  67.    IF EOF(1) THEN PRINT "ERROR 1": STOP
  68.  LOOP UNTIL Nput$ <> ""
  69.  
  70.  C = 1
  71. '                                                   ' take 1st line ...
  72. SearchBox:
  73.  DO WHILE LEFT$(Nput$,1) = " "                       ' chop spaces off left end
  74.    Nput$ = MID$(Nput$,2): INCR C '             and count them ...
  75.  LOOP
  76.  
  77.  IF LEFT$(Nput$,1) <> "^" THEN
  78.    PRINT ">";Nput$;"<"
  79.    PRINT "ERROR 2 IN LINE";L;": BOX NOT FOUND":STOP
  80.  END IF
  81.  
  82. ' ===================== SET WINDOW DIMENSIONS ================================
  83.  
  84.  CornerCol = C: BoxTop = L  '                       top of box has been found
  85.  
  86.  
  87.  Wid = 1: DO UNTIL MID$(Nput$,Wid,1) <> "^": INCR Wid: LOOP  ' count carrots ...
  88.  DECR Wid,2
  89.  
  90.  O$ = "  DATA "+STR$(Wid)+","+STR$(BoxTop)+","+STR$(CornerCol)
  91.  LineBuffer$(1) = O$
  92.  
  93. ' ============= PARSE EACH LINE DOWN TO BOXBOTTOM =======================
  94.  
  95. ParseLines:
  96.  N = 2
  97.  DO
  98.    INCR L: LINE INPUT #1, Nput$
  99.    IF EOF(1) THEN PRINT "ERROR -- INPUT FILE INCOMPLETE": STOP
  100.    GOSUB Show
  101.  
  102. TrimLine:
  103.    C = 0
  104. '                                          remove blank spaces ...
  105.    DO WHILE LEFT$(Nput$,1) = " "
  106.      Nput$ = MID$(Nput$,2): INCR C
  107.    LOOP
  108.  
  109.   IF LEFT$(Nput$,1) = "^" THEN
  110.      Nput$ = MID$(Nput$,2): INCR C '             remove the carrot on the left ...
  111.    ELSE
  112.      PRINT "ERROR 4: LEFT SIDE OF BOX NOT INTACT": STOP
  113.    END IF
  114.  
  115. Check4Bottom:
  116.    IF LEFT$(Nput$,1) = "^" THEN
  117.        BoxBottom = L+1  '                               check for bottom
  118.    ELSE
  119.  
  120. Check4Fields:
  121.  
  122.        X = 0 '                 otherwise find the field locations in the line...
  123.        DO
  124.          INCR X: INCR C
  125.          IF MID$(Nput$,X,1) = "{" THEN '              if a field marker is found
  126.            MID$(Nput$,X) = " "  '                     replace it w/ a space ...
  127.            INCR Fld%
  128.            FL(Fld%) = L  '                          and plug its location into
  129.            FC(Fld%) = C  '                           arrays for later use ...
  130.          END IF
  131.          IF MID$(Nput$,X,1) = "}" THEN MID$(Nput$,X) = " " 'replace } w/ a space ...
  132.        LOOP UNTIL X >= LEN(Nput$)
  133.  
  134. TrimRightEndOff:
  135.        DO UNTIL RIGHT$(Nput$,1) <> " " AND RIGHT$(Nput$,1) <> "^"
  136.          Nput$ = LEFT$(Nput$,LEN(Nput$)-1)
  137.        LOOP
  138.  
  139. Goob:
  140.  
  141.       C = CornerCol + 1 '      Since the carrot has been trimmed off, that's
  142. '                               where the placement of what's left of Nput$
  143. '                                                 will start on screen ...
  144.       DO UNTIL LEFT$ (Nput$,1) <> " "
  145.          Nput$ = MID$(Nput$,2)
  146.          INCR C
  147.       LOOP
  148.  
  149.       IF Nput$ <> "" THEN
  150.          LineBuffer$ (N) = "  DATA " + CHR$(34) + Nput$ + CHR$(34) + ","_
  151.           + STR$(L) + "," + STR$(C)
  152.          INCR N
  153.       END IF
  154.  
  155.    END IF
  156.  
  157.  LOOP UNTIL BoxBottom
  158.  
  159. '         ============== WRITE TO TARGET FILE =================
  160. WriteLns:
  161.  
  162.  PRINT #2, "'   Begin PopWindow data for window {";FlNm$;"}"
  163.  PRINT #2, "'        note: created by PopWindow Writer (PWW) from ";FlNm$;".PW"
  164.  PRINT #2, ""
  165.  LineBuffer$(1) = LineBuffer$(1)+","+STR$(BoxBottom - BoxTop)
  166.  
  167.  '          and write first line of code
  168.  N = 1
  169.  DO UNTIL LineBuffer$(N) = ""
  170.     PRINT #2, LineBuffer$(N)
  171.     INCR N
  172.  LOOP
  173.  PRINT #2, "  DATA END"
  174. '         ===================== READ FIELD DATA =====================
  175. ReadFldData:
  176. PartTwo:
  177.  
  178.  PRINT #2, ""
  179.  Fld% = 0
  180.  DO
  181.    LINE INPUT #1,Nput$
  182.    GOSUB Show
  183.  LOOP UNTIL LEFT$(Nput$,1) = "\"
  184.  
  185. WritePtII:
  186.  DO
  187.   LINE INPUT #1,Nput$
  188.   GOSUB Show
  189.   IF Nput$ <> "" AND LEFT$(Nput$,1) <> " " THEN
  190.     INCR Fld%
  191.     O$ = "  DATA "+Nput$+","+STR$(FL(Fld%))+","+STR$(FC(Fld%))
  192.     PRINT #2, O$
  193.   END IF
  194.  LOOP UNTIL EOF(1)
  195.  Report$ = "              DONE, NO ERRORS -- OK"
  196.  IF FL(Fld%) = 0 THEN_
  197.     Report$ = "DONE. INPUT FILE ERROR -- TOO MANY FIELDS NAMED."
  198.  INCR Fld%
  199.  IF FL(Fld%) <> 0 THEN_
  200.   Report$ = "DONE. INPUT FILE ERROR -- TOO MANY FIELD LOCATION"+_
  201.     " MARKERS ({) IN DESIGN."
  202.  PRINT #2, "  DATA END"
  203.  
  204.  Print #2, ""
  205.  PRINT #2, "'  ";DATE$;", ";LEFT$(TIME$,5);_
  206.            ":   end of PopWindow data for window {";FlNm$;"}"
  207.  CLOSE
  208.  PRINT: PRINT "     "; Report$
  209.  IF Report$ <> "              DONE, NO ERRORS -- OK" THEN
  210.    PLAY "O3 B8 P8 G4"
  211.    DO: LOOP UNTIL INKEY$ <> ""
  212.  END IF
  213.  END
  214.  
  215. '               <<<<<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>
  216.  
  217. QT:
  218.  STOP
  219.  RETURN
  220.  
  221. NoSuchInputFl:
  222.      PRINT:PRINT:PRINT "    ERROR -- Input File ";FlNm$;".PW not found"
  223.      PRINT: END 1
  224.  
  225.  
  226. Show:
  227.   LOCATE L0, C0, 0
  228.   PRINT USING "###"; IFLine
  229.   INCR IFLine
  230.   PRINT
  231.   RETURN
  232.  
  233.